<html>
<head>
 <!--
    CPAINT (Cross-Platform Asynchronous INterface Toolkit) - Version 2

    http://sf.net/projects/cpaint
    
    released under the terms of the GPL
    see http://www.fsf.org/licensing/licenses/gpl.txt for details

    authors:  Paul Sullivan <wiley14@gmail.com>, Dominique Stender <dstender@st-webdevelopment.de>
    Copyright (c) 2005-2006 Paul Sullivan, Dominique Stender - http://sf.net/projects/cpaint
  //-->
	<title>cpaint2 concurrency test</title>
	<script type="text/javascript" src="../../cpaint2.inc.compressed.js"></script>
	<script type="text/javascript">
	<!--
    var count = 0;
		var cp = new cpaint();
		cp.set_async(true);
    cp.set_persistent_connection(false);
    cp.set_debug(0);
	
		function get_time() {
      count                                         = 0;
      document.getElementById('response').innerHTML = '';
      
      for (var i = 0; i < 20; i++) {
  			cp.call('concurrency.php', 'get_time', response);
      }
      
			return false;
		}

		function response(result) {
      count++;
			document.getElementById('response').innerHTML = count 
                                                    + ': '
                                                    + result.ajaxResponse[0].time[0].data 
                                                    + "<br />\n"
                                                    + document.getElementById('response').innerHTML;
		}
	//-->
	</script>
</head>
<body>
	This script tests the threadsafety of cpaint2.<br />
  While AJAX is built from the ground up to be able to handle asynchronous request / response pairs,
  this doesn't mean that the application frontend that uses AJAX can handle situations where
  multiple open requests exist at the same time.<br />
  CPAINT can.<br />
  <br />
  When clicking on the button below the current system time is retrieved from the backend <strong>twenty times</strong> in fast succession. 
  The backend is configured to respond with a random delay of several seconds. After clicking this button 
  you will see the effect: The times shown as response might not be in chronological order but yet all responses
  will appear after some time.
	<br />
	<form action="#" onSubmit="return get_time()">
		<input type="submit" value="get time" />
	</form>
	<div id="response"></div>
</body>
</html>
